package cal

import (
	"idle/internal/game/attr"
	"idle/internal/game/hero"
	"idle/pkg/config"
)

// 生命值计算器
type HpAttrCal struct {
}

func (b *HpAttrCal) Cal(h *hero.Hero) {
	jobConfig := config.GetJobConfig(int(h.Job))
	baseHp := jobConfig.BaseHp + h.Lv*jobConfig.LvToHp + h.GetAttr(attr.Vit)*jobConfig.VitToHp
	h.SetAttr(attr.BaseHp, baseHp)

	hp := baseHp*(100+h.GetAttr(attr.ExtHpRatio))/100 + h.GetAttr(attr.ExtHp)
	h.SetAttr(attr.Hp, hp)
	h.Hp = hp
}

func (b HpAttrCal) name() {

}

func (b *HpAttrCal) AssociatedAttr() []attr.Attribute {
	return []attr.Attribute{
		attr.Vit,
		attr.Hp,
		attr.BaseHp,
		attr.ExtHpRatio,
		attr.ExtHp,
	}
}
